package com.newtouch.bxzs.enterprise.controller;

import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import com.newtouch.bxzs.enterprise.config.MyLog;
import com.newtouch.bxzs.enterprise.model.bo.PersonalCustomerGroupBO;
import com.newtouch.bxzs.enterprise.model.vo.CustomerVO;
import com.newtouch.bxzs.enterprise.model.vo.PersonalCustomerGroupVO;
import com.newtouch.bxzs.enterprise.service.PersonalCustomerGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 个人客户分组控制器
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2020/12/25 9:43</td>
 * <td>yuanjie</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author yuanjie
 * @version 1.0.0
 * @since 1.0.0
 */
@Api(tags = "个人客户分组管理")
@RestController
@RequestMapping(value = "/personalCustomerGroupController")
@SuppressWarnings("unchecked")
public class PersonalCustomerGroupController {

    @Autowired
    private PersonalCustomerGroupService personalCustomerGroupService;

    /**
     * 静态变量：系统日志
     */
    private static final Log logger = LogFactory.getLog(PersonalCustomerController.class);

    @ApiOperation(value = "获取个人客户分组列表信息")
    @GetMapping("/getCustomerGroupList")
    @MyLog(systemFunctionName = "个人客户分组管理", systemFunctionUrl = "/personalCustomerGroupController/getCustomerGroupList", userOperationType = 4, userOperationSummary = "获取个人客户分组列表信息")
    public BaseResponse<PersonalCustomerGroupBO> getGroupList() {
        logger.info("获取个人客户分组列表信息");
        return RespGenerator.returnOK(personalCustomerGroupService.getGroupList());
    }

    @ApiOperation(value = "增加或者修改个人客户分组信息")
    @PostMapping("/modifyPersonalCustomerGroup")
    @MyLog(systemFunctionName = "个人客户分组管理", systemFunctionUrl = "/personalCustomerGroupController/modifyPersonalCustomerGroup", userOperationType = 5, userOperationSummary = "增加或者修改个人客户分组信息")
    public BaseResponse<PersonalCustomerGroupBO> modifyPersonalCustomerGroup(@RequestBody PersonalCustomerGroupVO personalCustomerGroupVO) {
        return RespGenerator.returnOK(personalCustomerGroupService.modifyPersonalCustomerGroup(personalCustomerGroupVO));
    }

    @ApiOperation(value = "删除个人客户分组")
    @PostMapping("/deletePersonalCustomerGroup")
    @MyLog(systemFunctionName = "个人客户分组管理", systemFunctionUrl = "/personalCustomerGroupController/deletePersonalCustomerGroup", userOperationType = 3, userOperationSummary = "删除个人客户分组")
    public BaseResponse<PersonalCustomerGroupBO> deletePersonalCustomerGroup(@RequestBody PersonalCustomerGroupVO personalCustomerGroupVO) {
        return RespGenerator.returnOK(personalCustomerGroupService.deletePersonalCustomerGroup(personalCustomerGroupVO));
    }

    @ApiOperation(value = "分组添加客户")
    @PostMapping("/insertGroupCustomer")
    @MyLog(systemFunctionName = "个人客户分组管理", systemFunctionUrl = "/personalCustomerGroupController/insertGroupCustomer", userOperationType = 1, userOperationSummary = "分组添加客户")
    public BaseResponse<PersonalCustomerGroupBO> insertGroupCustomer(@RequestBody PersonalCustomerGroupVO personalCustomerGroupVO) {
        return RespGenerator.returnOK(personalCustomerGroupService.insertGroupCustomer(personalCustomerGroupVO));
    }

    @ApiOperation(value = "分组移除客户")
    @PostMapping("/deleteGroupCustomer")
    @MyLog(systemFunctionName = "个人客户分组管理", systemFunctionUrl = "/personalCustomerGroupController/deleteGroupCustomer", userOperationType = 3, userOperationSummary = "分组移除客户")
    public BaseResponse<PersonalCustomerGroupBO> deleteGroupCustomer(@RequestBody PersonalCustomerGroupVO personalCustomerGroupVO) {
        return RespGenerator.returnOK(personalCustomerGroupService.deleteGroupCustomer(personalCustomerGroupVO));
    }

    @ApiOperation(value = "获取可添加的客户列表")
    @PostMapping("/getEnableAddCustomerList")
    @MyLog(systemFunctionName = "个人客户分组管理", systemFunctionUrl = "/personalCustomerGroupController/getEnableAddCustomerList", userOperationType = 4, userOperationSummary = "获取可添加的客户列表")
    public BaseResponse<PersonalCustomerGroupBO> getEnableAddCustomerList(@RequestBody CustomerVO customerVO) {
        logger.info("获取可添加的客户列表信息");
        return RespGenerator.returnOK(personalCustomerGroupService.getEnableAddCustomerList(customerVO));
    }

}
